package top.suven.base.user.service;



import top.suven.base.http.exception.SystemRuntimeException;
import top.suven.base.oauth.dto.request.LoginConsumerRequestDto;
import top.suven.base.user.dto.request.*;
import top.suven.base.user.dto.response.BindTasePadResponseDto;
import top.suven.base.user.dto.response.ScoreGradeResponseDto;
import top.suven.base.user.dto.response.ThirdLoginResponseDto;
import top.suven.base.user.dto.response.UserResponseDto;

import java.util.List;
import java.util.Map;

/**
 * @ClassName:UserService.java
 * @Description:用户服务类
 * @Author aric
 * @Date 2018/5/16 下午4:20
 * @Copyright: (c) 2018 gc by https://www.gc.com.cn/
 * @Version : 1.0.0
 * --------------------------------------------------------
 * modifyer    modifyTime                 comment
 * heweijie     2018-5-22 11:51:30      添加getUserById方法
 * --------------------------------------------------------
 */
public interface UserService {

    /**
     * @Title:
     * @Description: 根据用户邮箱或者用户号码获取userId,并且随机生成signkey，并且设置在redis中
     * @param
     * @return
     * @author liulu
     * @date 2018/5/17 14:21
     */
    public UserResponseDto getKeyByUserAccount(UserRequestDto vo) throws SystemRuntimeException;

    /**
     * @Title:
     * @Description: 根据用户邮箱查询用户信息
     * @param:userEmail:用户邮箱地址
     * @return  UserResponseDto
     * @author liulu
     * @date 2018/5/17 11:15
     */
     UserResponseDto getUserByUserEmail(UserRequestDto dto) throws SystemRuntimeException;

    /**
     * @Title:
     * @Description: 根据用户手机号码查询用户信息
     * @param:userMobilePhone:用户号码
     * @return UserResponseDto
     * @author liulu
     * @date 2018/5/17 11:16
     */
     UserResponseDto getUserByUserMobilePhone(UserRequestDto dto) throws SystemRuntimeException;

    /**
     * @Title:
     * @Description:根据key，value，time保存redis
     * @param
     * @return
     * @author liulu
     * @date 2018/5/18 11:10
     */
     boolean saveRedisValue(RedisRequestDto redisRequestDto) throws SystemRuntimeException;
     /**
     * @Title: 获取用户信息
     * @Description: 
     * @param userRequestDto {@link UserRequestDto}
     * @return {@link UserResponseDto}&gt;
     * <p>
     *  --------------------------------------------------------
     *  modifyer    modifyTime                 comment
     *  
     *  --------------------------------------------------------
     * </p>
     * @author aric
     * @date 2018/5/16 下午4:23
     */
    UserResponseDto getUserInfo(UserRequestDto userRequestDto) throws SystemRuntimeException;


    /**
     * @Title: 根据id找用户对象
     * @Description:
     * @param
     * @return
     * @author heweijie
     * @date 2018/5/22 11:51
     * --------------------------------------------------------
     * modifyer    modifyTime                 comment
     *
     * --------------------------------------------------------
     */
     UserResponseDto getUserById(long userId) throws SystemRuntimeException;


    /**
     * @Title: 根据用户手机唯一标识码找该用户绑定体验设备的次数（验证第三方登录）
     * @Description:
     * @param padUnique firstProbationalStatus
     * @return {@link UserResponseDto}&gt;
     * <p>
     *  --------------------------------------------------------
     *  modifyer    modifyTime                 comment
     *
     *  --------------------------------------------------------
     * </p>
     * @author aric
     * @date 2018/5/16 下午4:23
     */
    int getCountByPadUniqueAndFirstProbationalStatus(String padUnique, String... firstProbationalStatus) throws SystemRuntimeException;

    /**
     * @Title:
     * @Description: 根据redisKey查询value
     * @param
     * @return
     * @author liulu
     * @date 2018/5/22 16:15
     */
     String getValueByRedisKey(RedisRequestDto redisRequestDto) throws SystemRuntimeException;

    /**
     * @Title:
     * @Description:
     * @param
     * @return
     * @author liulu
     * @date 2018/5/22 16:57
     */
     boolean delValueByRedisKey(RedisRequestDto redisRequestDto) throws SystemRuntimeException;


    /**
     * @Title:
     * @Description: 第三方登录,如果是第一次登录保存用户信息
     * @param{openid:登录返回的openId,thirdType:第三方登录的类型,String ip,source:用户来源,v:客户端app版本,client:客户端类型,imei手机,unionid:登录返回的unionid}
     * @return
     * @author liulu
     * @date 2018/5/23 20:39
     */
     UserResponseDto saveThirdLoginUser(UserRequestDto userRequestDto) throws SystemRuntimeException;

    /**
     * @Title:
     * @Description:根据openidType，openid（非微信登录），unionid（微信登录）查询用户信息
     * @param
     * @return
     * @author liulu
     * @date 2018/5/24 11:22
     */
     UserResponseDto selectThirdLoginUser(UserRequestDto userRequestDto) throws SystemRuntimeException;

    /**
     * @Title:
     * @Description:修改用户申请体验设备状态
     * @param
     * @return
     * @author liulu
     * @date 2018/5/24 11:22
     */
     boolean updateFirstPorbationalStatus(UserRequestDto userRequestDto) throws SystemRuntimeException;


    /**
     * @Title: 增加用户绑定过的设备数 更新普通设备(体验设备)状态为非首次申请
     * @Description:
     * @param userId padGrade padCount status
     * @return
     * <p>
     *  --------------------------------------------------------
     *  modifyer    modifyTime                 comment
     *
     *  --------------------------------------------------------
     * </p>
     * @author aric
     * @date 2018/5/16 下午4:23
     */
    int updateBoundPadCountAndFirstStatus(long userId, int padGrade, int padCount, int status) throws SystemRuntimeException;


    /**
     * @Title: 增加用户绑定过的设备数
     * @Description:
     * @param userId padCount
     * @return
     * <p>
     *  --------------------------------------------------------
     *  modifyer    modifyTime                 comment
     *
     *  --------------------------------------------------------
     * </p>
     * @author aric
     * @date 2018/5/16 下午4:23
     */
    boolean updateBoundPadCount(long userId, int padCount) throws SystemRuntimeException;

    /**
     * @Title:
     * @Description: 修改用户登录时间
     * @param
     * @return
     * @author liulu
     * @date 2018/5/29 18:24
     */
     boolean updateUserLoginTime(UserRequestDto userRequestDto) throws SystemRuntimeException;

    /**
     * @Title:
     * @Description: 设置redis锁
     * @param
     * @return
     * @author liulu
     * @date 2018/5/22 16:57
     */
    boolean setCacheLock(RedisRequestDto redisRequestDto) throws SystemRuntimeException;

    /**
     * @Title:
     * @Description: 用户登录校验
     * @param userRequestDto:userName;//用户名称,loginFailedMaxInvlid;//登录失败允许次数,configLoginErrorTime;//登录失败的时间,在多少时间内允许失败的次数
     *           validCode;//登录时的图形验证码;//checkNewVersion接口生成对客户端而言的唯一字符串checkWinstLoginOnOff;//非工作室人员是否可以登录工作室客户端的开关
     *          checkRedfingerLogin;//非个人会员是否可以登录非工作室的客户端的开关sign;//客户端将signkey+密码md5加密后的值uuid;//checkNewVersion接口生成对客户端而言的唯一字符串
     * @return
     * @author liulu
     * @date 2018/5/31 17:45
     */
     UserResponseDto checkLoginCount(UserRequestDto userRequestDto) throws SystemRuntimeException;


    /**
     * @Title:
     * @Description: 判断用户是否申请体验设备
     * @param requestDto：firstProbationalStatus：是否申请过体验设备状态boundPadCount：设备一共绑定过的设备userSource;//用户来源
     *         autoBindTasteOnOff;//绑定体验设备开关tastePadLimtTimeStr;//同一ip或者cuid规定申请体验设备的时间限制tastePadLimtCountStr;//同一ip或者cuid规定申请体验设备个数限制
     *         cuid;//随机生成32码，是手机的唯一标识ip;//IP地址
     * @return
     * @author liulu
     * @date 2018/6/1 10:01
     */
     int isApplyTaste(UserRequestDto requestDto) throws SystemRuntimeException;

    /**
     * @Title:
     * @Description: 第三方登录包括qq，微信，微博登录
     * @param
     * @return
     * @author liulu
     * @date 2018/6/1 19:37
     */
     ThirdLoginResponseDto thirdLogin(ThirdLoginRequestDto thirdLoginRequestDto) throws SystemRuntimeException;

    /**
     * @Title:
     * @Description: 登录日志保存
     * @param
     * @return
     * @author liulu
     * @date 2018/6/4 11:33
     */
     void saveLoginLog(UserRequestDto userRequestDto, LoginConsumerRequestDto loginConsumerRequestDto) throws SystemRuntimeException;


    /**
     * @Title:
     * @Description: 检查用户是否具有体验设备
     * @param
     * @return
     * <p>
     *  --------------------------------------------------------
     *  modifyer    modifyTime                 comment
     *
     *  --------------------------------------------------------
     * </p>
     * @author aric
     * @date 2018/5/31 下午9:12
     */
    BindTasePadResponseDto checkUserTastePad(UserResponseDto userResponseDto, String source) throws SystemRuntimeException;

    /**
     * 获取用户信息，并判断是否存在点击home键操作
     * @param requestDto
     * @return
     * @throws SystemRuntimeException
     * @Title:
     * @Description: 更新红豆
     * @param
     * @return
     * <p>
     *  --------------------------------------------------------
     *  modifyer    modifyTime                 comment
     *
     *  --------------------------------------------------------
     * </p>
     * @author dengzhifu
     */
    UserResponseDto getUserAndTriggerClickHomeKey(UserClickHomeKeyRequestDto requestDto) throws SystemRuntimeException;

    /**
     * 根据用户id，boundPadCount累加1，更新FirstApplyStatus状态
     * @param userId
     * @return
     * @throws SystemRuntimeException
     * @author aric
     * @date 2018/6/21 下午3:49
     */
    void awardRbc(long userId, int rbc, String rbcLogType, String remark) throws SystemRuntimeException;

    /**
     * 根据用户id，取消更新 boundPadCount累加1 和 取消更新FirstApplyStatus状态
     * @param userId
     * @return
     * @throws SystemRuntimeException
     * @author aric
     * @date 2018/6/21 下午3:49
     */
    void awardScore(long taskId, long userId, long userTaskId, int score, int rbc, int oldScore, int oldScoreGrade, List<ScoreGradeResponseDto> scoreIntervalList) throws SystemRuntimeException;

 	/**
     * @Title:
     * @Description: 更新积分等级
     * @param
     * @return
     * @author aric
     * @date 2018/6/21 下午3:49
     */
    void updateScoreGrade(long userId, int scoreGrade) throws SystemRuntimeException;

	/**
     * @Title:
     * @Description: 注册接口从redis中获取值
     * @param
     * @return
     * @author liulu
     * @date 2018/7/2 16:20
     */
     UserResponseDto getSignUpRedisValue(UserRequestDto userRequestDto);

    /**
     * @Title:
     * @Description: 校验手机号码和imei，mac
     * @param
     * @return
     * @author liulu
     * @date 2018/7/2 17:23
     */
     boolean checkSignUp(UserRequestDto userRequestDto) throws SystemRuntimeException;

    /**
     * @Title:
     * @Description: 保存用户信息和用户账号信息
     * @param
     * @return
     * @author liulu
     * @date 2018/7/2 19:52
     */
     UserResponseDto saveUser(UserRequestDto userRequestDto);

    /**
     * @Title:
     * @Description:注册时删除短信验证和号码的redis
     * @param
     * @return
     * @author liulu
     * @date 2018/7/3 11:16
     */
     void delSignUpRedis(UserRequestDto userRequestDto);

    /**
     * @Title:
     * @Description: 获取用户MAP列表
     * @param
     * @return
     * <p>
     *  --------------------------------------------------------
     *  modifyer    modifyTime                 comment
     *
     *  --------------------------------------------------------
     * </p>
     * @author aric
     * @date 2018/6/21 下午3:49
     */
     Map<Long,UserResponseDto> getUserMapByIdList(List<Long> userIds) throws SystemRuntimeException ;

     /**
      * @Description: 更新用户信息
      * @param dto
      * @return
      * @author xiexiaodong
      * @date 2018/8/22 上午10:53
      */
     void updateUserIgnoreNull(UpdateUserRequestDto dto) throws SystemRuntimeException;



    void doReceiveAward(List<FinishTaskDto> finishTaskDtos)throws SystemRuntimeException;
}
